package cn.ibizlab.assetmanagement.assetapi.rest;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.assetmanagement.assetapi.dto.*;
import cn.ibizlab.assetmanagement.assetapi.mapping.*;
import cn.ibizlab.assetmanagement.core.workorder.domain.EAMWorkOrder;
import cn.ibizlab.assetmanagement.core.workorder.service.IEAMWorkOrderService;
import cn.ibizlab.assetmanagement.core.workorder.filter.EAMWorkOrderSearchContext;
import cn.ibizlab.assetmanagement.util.annotation.VersionCheck;

@Slf4j
@Api(tags = {"工单" })
@RestController("AssetApi-eamworkorder")
@RequestMapping("")
public class EAMWorkOrderResource {

    @Autowired
    public IEAMWorkOrderService eamworkorderService;

    @Autowired
    @Lazy
    public EAMWorkOrderMapping eamworkorderMapping;

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "新建工单", tags = {"工单" },  notes = "新建工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> create(@RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "批量新建工单", tags = {"工单" },  notes = "批量新建工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatch(@RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        eamworkorderService.createBatch(eamworkorderMapping.toDomain(eamworkorderdtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "更新工单", tags = {"工单" },  notes = "更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> update(@PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
		EAMWorkOrder domain  = eamworkorderMapping.toDomain(eamworkorderdto);
        domain .setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain );
		EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain );
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "批量更新工单", tags = {"工单" },  notes = "批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatch(@RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        eamworkorderService.updateBatch(eamworkorderMapping.toDomain(eamworkorderdtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "删除工单", tags = {"工单" },  notes = "删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> remove(@PathVariable("eamworkorder_id") String eamworkorder_id) {
         return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "批量删除工单", tags = {"工单" },  notes = "批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "获取工单", tags = {"工单" },  notes = "获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> get(@PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "获取工单草稿", tags = {"工单" },  notes = "获取工单草稿")
	@RequestMapping(method = RequestMethod.GET, value = "/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraft() {
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(new EAMWorkOrder())));
    }

    @ApiOperation(value = "检查工单", tags = {"工单" },  notes = "检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKey(@RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "保存工单", tags = {"工单" },  notes = "保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamworkorders/save")
    public ResponseEntity<Boolean> save(@RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "批量保存工单", tags = {"工单" },  notes = "批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatch(@RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        eamworkorderService.saveBatch(eamworkorderMapping.toDomain(eamworkorderdtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "获取下级工单", tags = {"工单" } ,notes = "获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchChildWO(EAMWorkOrderSearchContext context) {
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
        return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "查询下级工单", tags = {"工单" } ,notes = "查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchChildWO(@RequestBody EAMWorkOrderSearchContext context) {
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "获取DEFAULT", tags = {"工单" } ,notes = "获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchDefault(EAMWorkOrderSearchContext context) {
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
        return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "查询DEFAULT", tags = {"工单" } ,notes = "查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchDefault(@RequestBody EAMWorkOrderSearchContext context) {
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据维护申请建立工单", tags = {"工单" },  notes = "根据维护申请建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamapplies/{eamapply_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据维护申请批量建立工单", tags = {"工单" },  notes = "根据维护申请批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据维护申请更新工单", tags = {"工单" },  notes = "根据维护申请更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据维护申请批量更新工单", tags = {"工单" },  notes = "根据维护申请批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据维护申请删除工单", tags = {"工单" },  notes = "根据维护申请删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据维护申请批量删除工单", tags = {"工单" },  notes = "根据维护申请批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMApply(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据维护申请获取工单", tags = {"工单" },  notes = "根据维护申请获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据维护申请获取工单草稿", tags = {"工单" },  notes = "根据维护申请获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamapplies/{eamapply_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMApply(@PathVariable("eamapply_id") String eamapply_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setWooriginid(eamapply_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据维护申请检查工单", tags = {"工单" },  notes = "根据维护申请检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamapplies/{eamapply_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据维护申请保存工单", tags = {"工单" },  notes = "根据维护申请保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamapplies/{eamapply_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据维护申请批量保存工单", tags = {"工单" },  notes = "根据维护申请批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamapplies/{eamapply_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护申请获取下级工单", tags = {"工单" } ,notes = "根据维护申请获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamapplies/{eamapply_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMApply(@PathVariable("eamapply_id") String eamapply_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护申请查询下级工单", tags = {"工单" } ,notes = "根据维护申请查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamapplies/{eamapply_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护申请获取DEFAULT", tags = {"工单" } ,notes = "根据维护申请获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamapplies/{eamapply_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMApply(@PathVariable("eamapply_id") String eamapply_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护申请查询DEFAULT", tags = {"工单" } ,notes = "根据维护申请查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamapplies/{eamapply_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMApply(@PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据资产建立工单", tags = {"工单" },  notes = "根据资产建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setAssetid(eamasset_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据资产批量建立工单", tags = {"工单" },  notes = "根据资产批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setAssetid(eamasset_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据资产更新工单", tags = {"工单" },  notes = "根据资产更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassets/{eamasset_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setAssetid(eamasset_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据资产批量更新工单", tags = {"工单" },  notes = "根据资产批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassets/{eamasset_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setAssetid(eamasset_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据资产删除工单", tags = {"工单" },  notes = "根据资产删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassets/{eamasset_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据资产批量删除工单", tags = {"工单" },  notes = "根据资产批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassets/{eamasset_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMAsset(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据资产获取工单", tags = {"工单" },  notes = "根据资产获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamassets/{eamasset_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据资产获取工单草稿", tags = {"工单" },  notes = "根据资产获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamassets/{eamasset_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMAsset(@PathVariable("eamasset_id") String eamasset_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setAssetid(eamasset_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据资产检查工单", tags = {"工单" },  notes = "根据资产检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据资产保存工单", tags = {"工单" },  notes = "根据资产保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setAssetid(eamasset_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据资产批量保存工单", tags = {"工单" },  notes = "根据资产批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setAssetid(eamasset_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产获取下级工单", tags = {"工单" } ,notes = "根据资产获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamassets/{eamasset_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMAsset(@PathVariable("eamasset_id") String eamasset_id,EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产查询下级工单", tags = {"工单" } ,notes = "根据资产查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamassets/{eamasset_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产获取DEFAULT", tags = {"工单" } ,notes = "根据资产获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamassets/{eamasset_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMAsset(@PathVariable("eamasset_id") String eamasset_id,EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产查询DEFAULT", tags = {"工单" } ,notes = "根据资产查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamassets/{eamasset_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMAsset(@PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据维护计划建立工单", tags = {"工单" },  notes = "根据维护计划建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamplans/{eamplan_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据维护计划批量建立工单", tags = {"工单" },  notes = "根据维护计划批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据维护计划更新工单", tags = {"工单" },  notes = "根据维护计划更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据维护计划批量更新工单", tags = {"工单" },  notes = "根据维护计划批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据维护计划删除工单", tags = {"工单" },  notes = "根据维护计划删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据维护计划批量删除工单", tags = {"工单" },  notes = "根据维护计划批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMPlan(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据维护计划获取工单", tags = {"工单" },  notes = "根据维护计划获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据维护计划获取工单草稿", tags = {"工单" },  notes = "根据维护计划获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamplans/{eamplan_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMPlan(@PathVariable("eamplan_id") String eamplan_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setWooriginid(eamplan_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据维护计划检查工单", tags = {"工单" },  notes = "根据维护计划检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamplans/{eamplan_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据维护计划保存工单", tags = {"工单" },  notes = "根据维护计划保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamplans/{eamplan_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据维护计划批量保存工单", tags = {"工单" },  notes = "根据维护计划批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamplans/{eamplan_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护计划获取下级工单", tags = {"工单" } ,notes = "根据维护计划获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamplans/{eamplan_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMPlan(@PathVariable("eamplan_id") String eamplan_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护计划查询下级工单", tags = {"工单" } ,notes = "根据维护计划查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamplans/{eamplan_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护计划获取DEFAULT", tags = {"工单" } ,notes = "根据维护计划获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamplans/{eamplan_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMPlan(@PathVariable("eamplan_id") String eamplan_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据维护计划查询DEFAULT", tags = {"工单" } ,notes = "根据维护计划查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamplans/{eamplan_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMPlan(@PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据资产维护申请建立工单", tags = {"工单" },  notes = "根据资产维护申请建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据资产维护申请批量建立工单", tags = {"工单" },  notes = "根据资产维护申请批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据资产维护申请更新工单", tags = {"工单" },  notes = "根据资产维护申请更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据资产维护申请批量更新工单", tags = {"工单" },  notes = "根据资产维护申请批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据资产维护申请删除工单", tags = {"工单" },  notes = "根据资产维护申请删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据资产维护申请批量删除工单", tags = {"工单" },  notes = "根据资产维护申请批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMAssetEAMApply(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据资产维护申请获取工单", tags = {"工单" },  notes = "根据资产维护申请获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据资产维护申请获取工单草稿", tags = {"工单" },  notes = "根据资产维护申请获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setWooriginid(eamapply_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据资产维护申请检查工单", tags = {"工单" },  notes = "根据资产维护申请检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据资产维护申请保存工单", tags = {"工单" },  notes = "根据资产维护申请保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据资产维护申请批量保存工单", tags = {"工单" },  notes = "根据资产维护申请批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护申请获取下级工单", tags = {"工单" } ,notes = "根据资产维护申请获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护申请查询下级工单", tags = {"工单" } ,notes = "根据资产维护申请查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护申请获取DEFAULT", tags = {"工单" } ,notes = "根据资产维护申请获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护申请查询DEFAULT", tags = {"工单" } ,notes = "根据资产维护申请查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMAssetEAMApply(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据功能位置资产建立工单", tags = {"工单" },  notes = "根据功能位置资产建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setAssetid(eamasset_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据功能位置资产批量建立工单", tags = {"工单" },  notes = "根据功能位置资产批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setAssetid(eamasset_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据功能位置资产更新工单", tags = {"工单" },  notes = "根据功能位置资产更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setAssetid(eamasset_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据功能位置资产批量更新工单", tags = {"工单" },  notes = "根据功能位置资产批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setAssetid(eamasset_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据功能位置资产删除工单", tags = {"工单" },  notes = "根据功能位置资产删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据功能位置资产批量删除工单", tags = {"工单" },  notes = "根据功能位置资产批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMLocationEAMAsset(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据功能位置资产获取工单", tags = {"工单" },  notes = "根据功能位置资产获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据功能位置资产获取工单草稿", tags = {"工单" },  notes = "根据功能位置资产获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setAssetid(eamasset_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据功能位置资产检查工单", tags = {"工单" },  notes = "根据功能位置资产检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据功能位置资产保存工单", tags = {"工单" },  notes = "根据功能位置资产保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setAssetid(eamasset_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据功能位置资产批量保存工单", tags = {"工单" },  notes = "根据功能位置资产批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setAssetid(eamasset_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产获取下级工单", tags = {"工单" } ,notes = "根据功能位置资产获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id,EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产查询下级工单", tags = {"工单" } ,notes = "根据功能位置资产查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产获取DEFAULT", tags = {"工单" } ,notes = "根据功能位置资产获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id,EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产查询DEFAULT", tags = {"工单" } ,notes = "根据功能位置资产查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMLocationEAMAsset(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_assetid_eq(eamasset_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据资产维护计划建立工单", tags = {"工单" },  notes = "根据资产维护计划建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据资产维护计划批量建立工单", tags = {"工单" },  notes = "根据资产维护计划批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据资产维护计划更新工单", tags = {"工单" },  notes = "根据资产维护计划更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据资产维护计划批量更新工单", tags = {"工单" },  notes = "根据资产维护计划批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据资产维护计划删除工单", tags = {"工单" },  notes = "根据资产维护计划删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据资产维护计划批量删除工单", tags = {"工单" },  notes = "根据资产维护计划批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMAssetEAMPlan(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据资产维护计划获取工单", tags = {"工单" },  notes = "根据资产维护计划获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据资产维护计划获取工单草稿", tags = {"工单" },  notes = "根据资产维护计划获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setWooriginid(eamplan_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据资产维护计划检查工单", tags = {"工单" },  notes = "根据资产维护计划检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据资产维护计划保存工单", tags = {"工单" },  notes = "根据资产维护计划保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据资产维护计划批量保存工单", tags = {"工单" },  notes = "根据资产维护计划批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护计划获取下级工单", tags = {"工单" } ,notes = "根据资产维护计划获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护计划查询下级工单", tags = {"工单" } ,notes = "根据资产维护计划查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护计划获取DEFAULT", tags = {"工单" } ,notes = "根据资产维护计划获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据资产维护计划查询DEFAULT", tags = {"工单" } ,notes = "根据资产维护计划查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMAssetEAMPlan(@PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据功能位置资产维护申请建立工单", tags = {"工单" },  notes = "根据功能位置资产维护申请建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据功能位置资产维护申请批量建立工单", tags = {"工单" },  notes = "根据功能位置资产维护申请批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据功能位置资产维护申请更新工单", tags = {"工单" },  notes = "根据功能位置资产维护申请更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据功能位置资产维护申请批量更新工单", tags = {"工单" },  notes = "根据功能位置资产维护申请批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据功能位置资产维护申请删除工单", tags = {"工单" },  notes = "根据功能位置资产维护申请删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据功能位置资产维护申请批量删除工单", tags = {"工单" },  notes = "根据功能位置资产维护申请批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMLocationEAMAssetEAMApply(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据功能位置资产维护申请获取工单", tags = {"工单" },  notes = "根据功能位置资产维护申请获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据功能位置资产维护申请获取工单草稿", tags = {"工单" },  notes = "根据功能位置资产维护申请获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setWooriginid(eamapply_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据功能位置资产维护申请检查工单", tags = {"工单" },  notes = "根据功能位置资产维护申请检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据功能位置资产维护申请保存工单", tags = {"工单" },  notes = "根据功能位置资产维护申请保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamapply_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据功能位置资产维护申请批量保存工单", tags = {"工单" },  notes = "根据功能位置资产维护申请批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setWooriginid(eamapply_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护申请获取下级工单", tags = {"工单" } ,notes = "根据功能位置资产维护申请获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护申请查询下级工单", tags = {"工单" } ,notes = "根据功能位置资产维护申请查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护申请获取DEFAULT", tags = {"工单" } ,notes = "根据功能位置资产维护申请获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护申请查询DEFAULT", tags = {"工单" } ,notes = "根据功能位置资产维护申请查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamapplies/{eamapply_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMLocationEAMAssetEAMApply(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamapply_id") String eamapply_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamapply_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据功能位置资产维护计划建立工单", tags = {"工单" },  notes = "根据功能位置资产维护计划建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> createByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
		eamworkorderService.create(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Create')")
    @ApiOperation(value = "根据功能位置资产维护计划批量建立工单", tags = {"工单" },  notes = "根据功能位置资产维护计划批量建立工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> createBatchByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.createBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "eamworkorder" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据功能位置资产维护计划更新工单", tags = {"工单" },  notes = "根据功能位置资产维护计划更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<EAMWorkOrderDTO> updateByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
        domain.setWorkorderid(eamworkorder_id);
		eamworkorderService.update(domain);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByEntities(this.eamworkorderMapping.toDomain(#eamworkorderdtos)),'iBizAssetManagement-EAMWorkOrder-Update')")
    @ApiOperation(value = "根据功能位置资产维护计划批量更新工单", tags = {"工单" },  notes = "根据功能位置资产维护计划批量更新工单")
	@RequestMapping(method = RequestMethod.PUT, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> updateBatchByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
            domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.updateBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.get(#eamworkorder_id),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据功能位置资产维护计划删除工单", tags = {"工单" },  notes = "根据功能位置资产维护计划删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    @Transactional
    public ResponseEntity<Boolean> removeByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
		return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.remove(eamworkorder_id));
    }

    @PreAuthorize("hasPermission(this.eamworkorderService.getEamworkorderByIds(#ids),'iBizAssetManagement-EAMWorkOrder-Remove')")
    @ApiOperation(value = "根据功能位置资产维护计划批量删除工单", tags = {"工单" },  notes = "根据功能位置资产维护计划批量删除工单")
	@RequestMapping(method = RequestMethod.DELETE, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/batch")
    public ResponseEntity<Boolean> removeBatchByEAMLocationEAMAssetEAMPlan(@RequestBody List<String> ids) {
        eamworkorderService.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.eamworkorderMapping.toDomain(returnObject.body),'iBizAssetManagement-EAMWorkOrder-Get')")
    @ApiOperation(value = "根据功能位置资产维护计划获取工单", tags = {"工单" },  notes = "根据功能位置资产维护计划获取工单")
	@RequestMapping(method = RequestMethod.GET, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/{eamworkorder_id}")
    public ResponseEntity<EAMWorkOrderDTO> getByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @PathVariable("eamworkorder_id") String eamworkorder_id) {
        EAMWorkOrder domain = eamworkorderService.get(eamworkorder_id);
        EAMWorkOrderDTO dto = eamworkorderMapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "根据功能位置资产维护计划获取工单草稿", tags = {"工单" },  notes = "根据功能位置资产维护计划获取工单草稿")
    @RequestMapping(method = RequestMethod.GET, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/getdraft")
    public ResponseEntity<EAMWorkOrderDTO> getDraftByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id) {
        EAMWorkOrder domain = new EAMWorkOrder();
        domain.setWooriginid(eamplan_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderMapping.toDto(eamworkorderService.getDraft(domain)));
    }

    @ApiOperation(value = "根据功能位置资产维护计划检查工单", tags = {"工单" },  notes = "根据功能位置资产维护计划检查工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/checkkey")
    public ResponseEntity<Boolean> checkKeyByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        return  ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.checkKey(eamworkorderMapping.toDomain(eamworkorderdto)));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdto),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据功能位置资产维护计划保存工单", tags = {"工单" },  notes = "根据功能位置资产维护计划保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/save")
    public ResponseEntity<Boolean> saveByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderDTO eamworkorderdto) {
        EAMWorkOrder domain = eamworkorderMapping.toDomain(eamworkorderdto);
        domain.setWooriginid(eamplan_id);
        return ResponseEntity.status(HttpStatus.OK).body(eamworkorderService.save(domain));
    }

    @PreAuthorize("hasPermission(this.eamworkorderMapping.toDomain(#eamworkorderdtos),'iBizAssetManagement-EAMWorkOrder-Save')")
    @ApiOperation(value = "根据功能位置资产维护计划批量保存工单", tags = {"工单" },  notes = "根据功能位置资产维护计划批量保存工单")
	@RequestMapping(method = RequestMethod.POST, value = "/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/savebatch")
    public ResponseEntity<Boolean> saveBatchByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody List<EAMWorkOrderDTO> eamworkorderdtos) {
        List<EAMWorkOrder> domainlist=eamworkorderMapping.toDomain(eamworkorderdtos);
        for(EAMWorkOrder domain:domainlist){
             domain.setWooriginid(eamplan_id);
        }
        eamworkorderService.saveBatch(domainlist);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护计划获取下级工单", tags = {"工单" } ,notes = "根据功能位置资产维护计划获取下级工单")
    @RequestMapping(method= RequestMethod.GET , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/fetchchildwo")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderChildWOByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchChildWO-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护计划查询下级工单", tags = {"工单" } ,notes = "根据功能位置资产维护计划查询下级工单")
    @RequestMapping(method= RequestMethod.POST , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/searchchildwo")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderChildWOByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchChildWO(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护计划获取DEFAULT", tags = {"工单" } ,notes = "根据功能位置资产维护计划获取DEFAULT")
    @RequestMapping(method= RequestMethod.GET , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/fetchdefault")
	public ResponseEntity<List<EAMWorkOrderDTO>> fetchEAMWorkOrderDefaultByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id,EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
        List<EAMWorkOrderDTO> list = eamworkorderMapping.toDto(domains.getContent());
	    return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizAssetManagement-EAMWorkOrder-searchDefault-all') and hasPermission(#context,'iBizAssetManagement-EAMWorkOrder-Get')")
	@ApiOperation(value = "根据功能位置资产维护计划查询DEFAULT", tags = {"工单" } ,notes = "根据功能位置资产维护计划查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/eamlocations/{eamlocation_id}/eamassets/{eamasset_id}/eamplans/{eamplan_id}/eamworkorders/searchdefault")
	public ResponseEntity<Page<EAMWorkOrderDTO>> searchEAMWorkOrderDefaultByEAMLocationEAMAssetEAMPlan(@PathVariable("eamlocation_id") String eamlocation_id, @PathVariable("eamasset_id") String eamasset_id, @PathVariable("eamplan_id") String eamplan_id, @RequestBody EAMWorkOrderSearchContext context) {
        context.setN_eamwooriginid_eq(eamplan_id);
        Page<EAMWorkOrder> domains = eamworkorderService.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(eamworkorderMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}
}

